home *** CD-ROM | disk | FTP | other *** search
/ FM Towns: Free Software Collection 4 / FM Towns Free Software Collection 4 - Disc 1.iso / t_os / wstype / source / asms.s next >
Text File  |  1991-10-18  |  5KB  |  367 lines

  1. /***   [asms.s]
  2. *
  3. *    アセンブリ いろいろ    (C)ささがわ
  4. *
  5. *    For GNU Assembler (GAS)
  6. *
  7. ***/
  8.  
  9.     .text
  10.  
  11. /* int Get_curdir(int drivenum, char *path) */
  12.     .align    2
  13. _Get_curdir:
  14.     .globl    _Get_curdir
  15.     enter    $0, $0
  16.     pushl    %esi
  17.     
  18.     movb    $0x47, %ah
  19.     movl    12(%ebp), %esi
  20.     movb    8(%ebp), %dl
  21.     int    $0x21
  22.     jc    cd_e
  23.     movw    $0, %ax
  24. cd_e:
  25.     movzwl    %ax, %eax
  26.     
  27.     popl    %esi
  28.     leave
  29.     ret
  30.  
  31. /* void Get_cdexinf(int *n, int *letter) */
  32.     .align    2
  33. _Get_cdexinf:
  34.     .globl    _Get_cdexinf
  35.     enter    $0, $0
  36.     pushl    %esi
  37.     pushl    %ebx
  38.     
  39.     movw    $0x1500, %ax
  40.     xorw    %bx, %bx
  41.     int    $0x2f
  42.     movl    8(%ebp), %esi
  43.     movzwl    %bx, %ebx
  44.     movl    %ebx, (%esi)
  45.     movl    12(%ebp), %esi
  46.     movzwl    %cx, %ecx
  47.     movl    %ecx, (%esi)
  48.     
  49.     popl    %ebx
  50.     popl    %esi
  51.     leave
  52.     ret
  53.  
  54. /* void _Pixelx(void *buf, int count, const void *table) */
  55.     .align    2
  56. __Pixelx:
  57.     .globl    __Pixelx
  58.     enter    $0, $0
  59.     pushl    %edi
  60.     pushl    %ebx
  61.     
  62.     cld
  63.     pushl    %ds
  64.     popl    %es
  65.     movl    8(%ebp), %edi
  66.     movl    12(%ebp), %ecx
  67.     movl    16(%ebp), %ebx
  68.     cmpl    $0, %ecx
  69.     jle    pixel_end
  70. pixel_l:
  71.     movb    (%edi), %al
  72.     xlatb
  73.     stosb
  74.     loop    pixel_l
  75.     
  76. pixel_end:
  77.     popl    %ebx
  78.     popl    %edi
  79.     leave
  80.     ret
  81.  
  82. /* void _Pixelstr(void *buf, const void *str, int n) */
  83.     .align    2
  84. __Pixelstr:
  85.     .globl    __Pixelstr
  86.     enter    $0, $0
  87.     pushl    %edi
  88.     pushl    %esi
  89.     pushl    %ebx
  90.     
  91.     movl    12(%ebp), %edi
  92.     xorl    %ecx, %ecx
  93. Pixel_str_loop:
  94.     cmpl    16(%ebp), %ecx
  95.     jae    Pixel_str_fin
  96.     
  97.     movb    (%edi, %ecx), %al
  98.     cmpb    $0x81, %al
  99.     jb    Pixel_str_han
  100.     cmpb    $0x9f, %al
  101.     jbe    Pixel_str_zen
  102.     cmpb    $0xe0, %al
  103.     jb    Pixel_str_han
  104.     cmpb    $0xfc, %al
  105.     jbe    Pixel_str_zen
  106.     jmp    Pixel_str_han
  107.     
  108. Pixel_str_han:
  109.     movb    (%edi, %ecx), %bl
  110.     movzbw    %bl, %bx
  111.     call    _Get_fntadr
  112.     
  113.     pushl    %ecx
  114.     pushl    %edi
  115.     
  116.     movl    8(%ebp), %edi
  117.     addl    %ecx, %edi
  118.     movl    16(%ebp), %edx
  119.     movl    $16, %ecx
  120. Pixel_str_l3:
  121.     movb    %es:(%esi), %al
  122.     incl    %esi
  123.     movb    %al, (%edi)
  124.     addl    %edx, %edi
  125.     loop    Pixel_str_l3
  126.     
  127.     popl    %edi
  128.     popl    %ecx
  129.     incl    %ecx
  130.     jmp    Pixel_str_loop
  131.     
  132. Pixel_str_zen:
  133.     movw    (%edi, %ecx), %bx
  134.     xchgb    %bl, %bh
  135.     call    _Get_fntadr
  136.     
  137.     pushl    %ecx
  138.     pushl    %edi
  139.     
  140.     movl    8(%ebp), %edi
  141.     addl    %ecx, %edi
  142.     movl    16(%ebp), %edx
  143.     movl    $16, %ecx
  144. Pixel_str_l4:
  145.     movw    %es:(%esi), %ax
  146.     incl    %esi
  147.     incl    %esi
  148.     movw    %ax, (%edi)
  149.     addl    %edx, %edi
  150.     loop    Pixel_str_l4
  151.     
  152.     popl    %edi
  153.     popl    %ecx
  154.     incl    %ecx
  155.     incl    %ecx
  156.     jmp    Pixel_str_loop
  157.     
  158. Pixel_str_fin:
  159.     popl    %ebx
  160.     popl    %esi
  161.     popl    %edi
  162.     leave
  163.     ret
  164.  
  165. /* void _Pixelstr2(void *buf, const void *str, const void *table, int n) */
  166.     .align    2
  167. __Pixelstr2:
  168.     .globl    __Pixelstr2
  169.     enter    $4, $0
  170.     pushl    %edi
  171.     pushl    %esi
  172.     pushl    %ebx
  173.     
  174.     movl    12(%ebp), %edi
  175.     movl    20(%ebp), %ecx
  176.     shl    $2, %ecx
  177.     movl    %ecx, -4(%ebp)
  178.     
  179.     xorl    %ecx, %ecx
  180. Pixel_str2_loop:
  181.     cmpl    20(%ebp), %ecx
  182.     jae    Pixel_str2_fin
  183.     
  184.     movb    (%edi, %ecx), %al
  185.     cmpb    $0x81, %al
  186.     jb    Pixel_str2_han
  187.     cmpb    $0x9f, %al
  188.     jbe    Pixel_str2_zen
  189.     cmpb    $0xe0, %al
  190.     jb    Pixel_str2_han
  191.     cmpb    $0xfc, %al
  192.     jbe    Pixel_str2_zen
  193.     jmp    Pixel_str2_han
  194.     
  195. Pixel_str2_han:
  196.     movb    (%edi, %ecx), %bl
  197.     movzbw    %bl, %bx
  198.     call    _Get_fntadr
  199.     
  200.     pushl    %ecx
  201.     pushl    %edi
  202.     
  203.     movl    -4(%ebp), %edx
  204.     movl    8(%ebp), %edi
  205.     movl    16(%ebp), %ebx
  206.     movl    $16, %ecx
  207. Pixel_str2_l3:
  208.     movb    %es:(%esi), %al
  209.     incl    %esi
  210.     movzbl    %al, %eax
  211.     movl    (%ebx, %eax, 4), %eax
  212.     movl    %eax, (%edi)
  213.     addl    %edx, %edi
  214.     loop    Pixel_str2_l3
  215.     
  216.     popl    %edi
  217.     popl    %ecx
  218.     addl    $4, 8(%ebp)
  219.     incl    %ecx
  220.     jmp    Pixel_str2_loop
  221.     
  222. Pixel_str2_zen:
  223.     movw    (%edi, %ecx), %bx
  224.     xchgb    %bl, %bh
  225.     call    _Get_fntadr
  226.     
  227.     pushl    %ecx
  228.     pushl    %edi
  229.     
  230.     movl    -4(%ebp), %edx
  231.     movl    8(%ebp), %edi
  232.     movl    16(%ebp), %ebx
  233.     movl    $16, %ecx
  234. Pixel_str2_l4:
  235.     movb    %es:(%esi), %al
  236.     incl    %esi
  237.     movzbl    %al, %eax
  238.     movl    (%ebx, %eax, 4), %eax
  239.     movl    %eax, (%edi)
  240.     movb    %es:(%esi), %al
  241.     incl    %esi
  242.     movzbl    %al, %eax
  243.     movl    (%ebx, %eax, 4), %eax
  244.     movl    %eax, 4(%edi)
  245.     addl    %edx, %edi
  246.     loop    Pixel_str2_l4
  247.     
  248.     popl    %edi
  249.     popl    %ecx
  250.     addl    $8, 8(%ebp)
  251.     incl    %ecx
  252.     incl    %ecx
  253.     jmp    Pixel_str2_loop
  254.     
  255. Pixel_str2_fin:
  256.     popl    %ebx
  257.     popl    %esi
  258.     popl    %edi
  259.     leave
  260.     ret
  261.  
  262.     .align    2
  263. _Get_fntadr:
  264.     .globl    _Get_fntadr
  265.     pushl    %edx
  266.     pushl    %ds
  267.     
  268.     cmpw    $0xff, %bx
  269.     ja    _Get_fntadr_zen
  270.     
  271.     movb    $0x00, %ah
  272.     movb    $0, %al
  273.     movb    $8, %dh
  274.     movb    $16, %dl
  275.     pushl    $0x0110
  276.     popl    %fs
  277.     lcall    %fs:(0xa0)
  278.     pushl    %ds
  279.     popl    %es
  280.     jmp    _Get_fntadr_fin
  281.     
  282. _Get_fntadr_zen:
  283.     cmpw    $0xec40, %bx
  284.     jl    _skip
  285.     movw    $0x8140, %bx
  286. _skip:
  287.     
  288.     movb    $0x02, %ah
  289.     pushl    $0x0110
  290.     popl    %fs
  291.     lcall    %fs:(0xa0)
  292.     
  293.     movb    $0x01, %ah
  294.     movb    $0, %al
  295.     movb    $16, %dh
  296.     movb    $16, %dl
  297.     pushl    $0x0110
  298.     popl    %fs
  299.     lcall    %fs:(0xa0)
  300.     pushl    %ds
  301.     popl    %es
  302.     
  303. _Get_fntadr_fin:
  304.     popl    %ds
  305.     popl    %edx
  306.     ret
  307.  
  308.  
  309.  
  310. /* segpatch */
  311.     .align    2
  312. _segpatch:
  313.     .globl    _segpatch
  314.     pushl    %ds
  315.     popl    %es
  316.     pushl    %ds
  317.     popl    %fs
  318.     pushl    %ds
  319.     popl    %gs
  320.     ret
  321.  
  322.  
  323.  
  324.     .align    2
  325. __TIMER_reset:
  326.     .globl    __TIMER_reset
  327.     enter    $0, $0
  328.     movl    $0, __TIMER_flag
  329.     movl    $0, __TIMER_count
  330.     movl    8(%ebp), %eax
  331.     movl    %eax, __TIMER_count_max
  332.     leave
  333.     ret
  334.  
  335.     .align    2
  336. __TIMER_sub:
  337.     .globl    __TIMER_sub
  338.     pushl    %eax
  339.     pushl    %edi
  340.     
  341.     movb    $0x17, %ah    /* FM タイマ A 再スタート */
  342.     pushl    %ds
  343.     popl    %gs
  344.     movl    SND_work, %edi
  345.     pushl    $0x0110
  346.     popl    %fs
  347.     lcall    %fs:(0x80)
  348.     
  349.     cmpl    $0, __TIMER_flag
  350.     jne    __TIMER_sub_end
  351.     incl    __TIMER_count
  352.     movl    __TIMER_count, %eax
  353.     cmpl    __TIMER_count_max, %eax
  354.     jb    __TIMER_sub_end
  355.     movl    $1, __TIMER_flag
  356. __TIMER_sub_end:
  357.     popl    %edi
  358.     popl    %eax
  359.     ret
  360.  
  361.     .data
  362. __TIMER_flag:    .long 0
  363.     .globl    __TIMER_flag
  364. __TIMER_count:    .long 0
  365. __TIMER_count_max:
  366.         .long 0
  367.